package com.visikard.item;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

public class ItemCouponsBuilderCreate implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	long fkUser;
	long fkKard;
	long couponID;
	String logos;
	String categoryName;
	String subCategoryName;
	String couponName;
	int campaignDetailValue;
	String conditions;
	String imageSpecial;
	String imageText1;
	String imageText2;
	String startDate; // MM/DD/YYYY
	String endDate; // MM/DD/YYYY
	String termAndCondition;
	String expireDate; // MM/dd/yyyy , Require
	String aboutbusiness;
	List<GetLocationSpecialItem> locations; // json EX :

	// [{address:"",latitude:"",longitude:""}.....]

	public ItemCouponsBuilderCreate() {
	}
	
	public ItemCouponsBuilderCreate(JSONObject job) {
		if (job == null)
			return;

		try {
			fkUser = job.optLong("fkUser", -1);
			fkKard = job.optLong("fkKard", -1);
			termAndCondition = job.optString("termandcondition", "");
			imageSpecial = job.optString("imageSpecial", "");
			startDate = job.optString("sstartDate", "");
			endDate = job.optString("sEndDate", "");
			conditions = job.optString("conditions", "");
 			expireDate = job.optString("expireDate", "");
			imageText1 = job.optString("imageText1", "");
			imageText2 = job.optString("imageText2", "");
			couponName = job.optString("couponName", "");
			campaignDetailValue = job.optInt("campaignDetailValue");
			aboutbusiness = job.optString("aboutbusiness", "");
			couponID = job.optLong("id");
			
			JSONArray arr = new JSONArray(job.getString("listSpecialLocation"));
			for (int i = 0; i < arr.length(); i++) {
				GetLocationSpecialItem loc = new GetLocationSpecialItem(arr.getJSONObject(i));
				locations.add(loc);
			}
				
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public String getLogos() {
		if (logos == null)
			return "";
		return logos;
	}

	public void setLogos(String logos) {
		this.logos = logos;
	}

	public String getCategoryName() {
		if (categoryName == null)
			return "";
		return categoryName;
	}

	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}

	public String getSubCategoryName() {
		if (subCategoryName == null)
			return "";
		return subCategoryName;
	}

	public void setSubCategoryName(String subCategoryName) {
		this.subCategoryName = subCategoryName;
	}

	public String getCouponName() {
		if (couponName == null)
			return "";
		return couponName;
	}

	public void setCouponName(String couponName) {
		this.couponName = couponName;
	}

	public int getCampaignDetailValue() {
		return campaignDetailValue;
	}

	public void setCampaignDetailValue(int campaignDetailValue) {
		this.campaignDetailValue = campaignDetailValue;
	}

	public String getConditions() {
		if (conditions == null)
			return "";
		return conditions;
	}

	public void setConditions(String conditions) {
		this.conditions = conditions;
	}

	public String getImageSpecial() {
		if (imageSpecial == null)
			return "";
		return imageSpecial;
	}

	public void setImageSpecial(String imageSpecial) {
		this.imageSpecial = imageSpecial;
	}

	public String getImageText1() {
		if (imageText1 == null)
			return "";
		return imageText1;
	}

	public void setImageText1(String imageText1) {
		this.imageText1 = imageText1;
	}

	public String getImageText2() {
		if (imageText2 == null)
			return "";
		return imageText2;
	}

	public void setImageText2(String imageText2) {
		this.imageText2 = imageText2;
	}

	public String getStartDate() {
		if (startDate == null)
			return "";
		return startDate;
	}

	public void setStartDate(String sstartDate) {
		this.startDate = sstartDate;
	}

	public String getEndDate() {
		if (endDate == null)
			return "";
		return endDate;
	}

	public void setsEndDate(String sEndDate) {
		this.endDate = sEndDate;
	}

	public String getTermAndCondition() {
		if (termAndCondition == null)
			return "";
		return termAndCondition;
	}

	public void setTermAndCondition(String termAndCondition) {
		this.termAndCondition = termAndCondition;
	}

	public String getExpireDate() {
		if (expireDate == null)
			return "";
		return expireDate;
	}

	public void setExpireDate(String expireDate) {
		this.expireDate = expireDate;
	}

	public String getAboutbusiness() {
		if (aboutbusiness == null)
			return "";
		return aboutbusiness;
	}

	public void setAboutbusiness(String aboutbusiness) {
		this.aboutbusiness = aboutbusiness;
	}

	public List<GetLocationSpecialItem> getLocations() {
		return locations;
	}

	public String getListLocationsJSON() {
		if(locations == null || locations.size() <= 0)
			return "[]";
		
		JSONArray jArr = new JSONArray();
		
		for (int i = 0; i < locations.size(); i++) {
			try {
				JSONObject jSon = new JSONObject();
				jSon.put("address", locations.get(i).getAddress());
				jSon.put("latitude", locations.get(i).getLattitue());
				jSon.put("longitude", locations.get(i).getLongitue());
				jArr.put(jSon);
			} catch (Exception e) {

			}
		}

		if (jArr.length() > 0) {
			return jArr.toString();
		} else {
			return "[]";
		}
	}

	public void setListSpecialLocation( List<GetLocationSpecialItem> listSpecialLocation) {
		this.locations = listSpecialLocation;
	}

	public long getFkUser() {
		return fkUser;
	}

	public void setFkUser(long fkUser) {
		this.fkUser = fkUser;
	}

	public long getFkKard() {
		return fkKard;
	}

	public void setFkKard(long fkKard) {
		this.fkKard = fkKard;
	}

	public long getCouponID() {
		return couponID;
	}

	public void setCouponID(long couponID) {
		this.couponID = couponID;
	}

	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}
	
	

}
